

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <stdarg.h>


#define TRACE() printf("%s\r\n", __FUNCTION__)


/*char *fva(const char *frmt, ...)
{
	static unsigned int hits = 0;
	static char text[8][32000];
	
	char	*ptext = text[(hits++)%8];
	
	va_list	argptr;

	va_start (argptr, frmt);
	vsnprintf (ptext, 31999, frmt, argptr);
	va_end (argptr);

	return ptext;
}  */


template <int size> class EVa {
	public:
		EVa	( const char *frmt, ... ) {
			va_list	argptr;
			va_start (argptr, frmt);
			vsnprintf (buffer, size-1, frmt, argptr);
			va_end (argptr);
		}
		
		~EVa	( void ) {
		}
		
		const char *c_str(void) const {
			return buffer;
		}
		
		operator const char* () const {
			return buffer;
		}
	private:
		EVa<size> &operator = (EVa<size> &other) {}
		EVa<size> ( EVa<size> &other ) {}
		char buffer[size];
	};

typedef EVa<512> va;

class C {
	public:
		C(int a) { TRACE(); }
		~C(){ TRACE(); }
	};


int main(int argc, char **argv)
{
	printf("va test\r\n");
	int n = 4;
	do {
		C c(2);	
		
		puts(va("FUCK %d : %s", 78, va("%s %s", "Hello", "World").c_str()));
		puts("Blah 2\r\n");
	} while (n--);

	getch();

	return 0;
}